<template>
  <div class="snow-page">
    <a-card title="网关详情" style="width: 99%" hoverable>
      <template #extra>
        <a-button size="mini" type="primary" @click="goBack">返回</a-button>
      </template>
      <a-descriptions title="" layout="vertical" bordered :column="5">
        <a-descriptions-item label="编码">{{ qiyeInfo.device_code }}</a-descriptions-item>
        <a-descriptions-item label="名称">{{ qiyeInfo.name }}</a-descriptions-item>
        <a-descriptions-item label="危险源编码">{{ qiyeInfo.cq_hazard_code }}</a-descriptions-item>
        <a-descriptions-item label="网关类型">{{ format558(qiyeInfo.cq_equip_type) }}</a-descriptions-item>
        <a-descriptions-item label="网关介质">{{ qiyeInfo.cq_equip_medium }}</a-descriptions-item>
        <a-descriptions-item label="通信协议">{{ qiyeInfo.iot_node_name }}</a-descriptions-item>
        <a-descriptions-item label="经纬度">{{ qiyeInfo.lonLat }}</a-descriptions-item>
        <a-descriptions-item label="数据协议">{{ qiyeInfo.iot_protocal_name }}</a-descriptions-item>
        <a-descriptions-item label="运行状态">{{ qiyeInfo.data ? qiyeInfo.data.iot_node_status : "" }}</a-descriptions-item>


        <a-descriptions-item label="仓间位置及编号">{{ qiyeInfo.cq_location_code }}</a-descriptions-item>
        <a-descriptions-item label="仓间火灾危险性评价">{{ qiyeInfo.cq_fire_evaluate }}</a-descriptions-item>
        <a-descriptions-item label="仓间最大存储量">{{ qiyeInfo.cq_max_storage }}</a-descriptions-item>
        <a-descriptions-item label="仓间储存物品类别">{{ qiyeInfo.cq_goods_type }}</a-descriptions-item>
        <a-descriptions-item label="实时储存物品的名称，数量">{{ qiyeInfo.cq_goods_name_num }}</a-descriptions-item>
        <a-descriptions-item label="储存物品堆放位置">{{ qiyeInfo.cq_goods_local }}</a-descriptions-item>
        <a-descriptions-item label="库存量">{{ qiyeInfo.cq_storage }}</a-descriptions-item>
        <a-descriptions-item label="周转量">{{ qiyeInfo.cq_turnover }}</a-descriptions-item>
        <a-descriptions-item label="仓间应急预案">{{ qiyeInfo.cq_emergency_plan }}</a-descriptions-item>
        <a-descriptions-item label="网关描述">{{ qiyeInfo.infos }}</a-descriptions-item>

        <a-descriptions-item label="上传周期">{{ qiyeInfo.frequency }}s</a-descriptions-item>
        <a-descriptions-item label="排序">{{ qiyeInfo.seq }}</a-descriptions-item>
        <a-descriptions-item label="创建时间">{{ formatTime(qiyeInfo.cq_create_date) }}</a-descriptions-item>
        <a-descriptions-item label="最后修改时间">{{ formatTime(qiyeInfo.cq_update_date) }}</a-descriptions-item>
      </a-descriptions>
    </a-card>
  </div>
</template>

<script setup lang="ts">
import { onMounted, ref } from "vue";
import { getDictBycodeAPI } from "@/api/modules/dictionary/index";
const router = useRouter();

const qiyeInfo = ref({}) as any;

onMounted(() => {
  getDictBycodeAPIfun2()
  let userInfo = JSON.parse(localStorage.getItem("user-info") as string);
  qiyeInfo.value = userInfo.sharedObject;

});

const options558 = ref([]);
async function getDictBycodeAPIfun2() {
  let res = await getDictBycodeAPI(558);
  if (res.status == 2) {
    options558.value = res.data;
  }
}

function format558(val) {

  for (let i = 0; i < options558.value.length; i++) {
    if (options558.value[i].dictionary_name == val) {
      return options558.value[i].name
    }

  }

}

function formatTime(specificTimestamp) {
  // 创建一个Date对象
  if (specificTimestamp) {
    let date = new Date(specificTimestamp);

    let year = date.getFullYear();
    let month = date.getMonth() + 1; // 月份从0开始，需要加1
    let day = date.getDate();

    // 格式化日期字符串
    let formattedDate = `${year}-${month < 10 ? "0" : ""}${month}-${day < 10 ? "0" : ""}${day}`;

    return formattedDate;
  }
}
function goBack() {
  router.back();
}
</script>





<style lang="scss" scoped></style>
